package com.module.home.ui.scoringFactors.provider

import androidx.recyclerview.widget.RecyclerView
import com.chad.library.adapter.base.provider.BaseItemProvider
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.common.app.data.bean.home.ScoringClassListBean
import com.common.base.utils.ViewUtils.getString
import com.common.base.widget.CustomTextView
import com.module.ble.utils.AllCardTypeConfig
import com.module.home.R

/**
 *
 * 作者：sosou
 *
 * 版本：1.0
 *
 * 创建日期：2025/08/27
 *
 * 描述：评分因素-圆环列表
 *
 * 修订历史：
 *
 */
class ScoringFactorsAnnulusListCardProvider(
    override val itemViewType: Int = AllCardTypeConfig.TYPE_CARD_SF_ANNULUS_LIST,
    override val layoutId: Int = R.layout.home_scoring_factors_annulus_list_crad_provider
) : BaseItemProvider<ScoringClassListBean>() {


    init {
    }

    override fun convert(helper: BaseViewHolder, item: ScoringClassListBean) {
        helper.setText(R.id.tvTitle,when(item.type){// "improvable","excellent","good"
            "excellent"->getString(R.string.common_excellent_hint2)
            "good"->getString(R.string.common_good_hint)
            "improvable"->getString(R.string.common_acceptable_hint2)
            "severity"->getString(R.string.common_not_good_hint2)
            else->getString(R.string.common_rail_unit)
        })
        helper.setBackgroundResource(R.id.imgLabel, when(item.type){// "improvable","excellent","good"
            "excellent"->R.drawable.bg_round_12b2b2_100
            "good"->R.drawable.bg_round_6a98f4_100
            "improvable"->R.drawable.bg_round_ff9f40_100
            "severity"->R.drawable.bg_round_f3607b_100
            else->R.drawable.bg_round_6a98f4_100
        })

        helper.setTextColor(R.id.tvTitle,when(item.type){// "improvable","excellent","good"
            "excellent"->R.color.c_12b2b2
            "good"->R.color.c_6a98f4
            "improvable"->R.color.c_ff9f40
            "severity"->R.color.c_f3607b
            else->R.color.c_6a98f4
        })
        val mAdapter = ScoringFactorsAnnulusItemAdapter(item.type)
        helper.getView<RecyclerView>(R.id.hrv).adapter = mAdapter
        mAdapter.setList(item.score_items)

    }

    override fun onViewHolderCreated(viewHolder: BaseViewHolder, viewType: Int) {
        super.onViewHolderCreated(viewHolder, viewType)
    }
}